package cn.iocoder.yudao.module.mini.dal.mysql.address;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.mini.dal.dataobject.address.MiniAddressDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.mini.controller.admin.address.vo.*;

/**
 * 用户地址 Mapper
 *
 * @author dzy
 */
@Mapper
public interface MiniAddressMapper extends BaseMapperX<MiniAddressDO> {

    default PageResult<MiniAddressDO> selectPage(AddressPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MiniAddressDO>()
                .eqIfPresent(MiniAddressDO::getCustomerId, reqVO.getCustomerId())
                .likeIfPresent(MiniAddressDO::getFullName, reqVO.getFullName())
                .eqIfPresent(MiniAddressDO::getMobile, reqVO.getMobile())
                .eqIfPresent(MiniAddressDO::getAddress, reqVO.getAddress())
                .eqIfPresent(MiniAddressDO::getLongitude, reqVO.getLongitude())
                .eqIfPresent(MiniAddressDO::getLatitude, reqVO.getLatitude())
                .eqIfPresent(MiniAddressDO::getDetailedAddress, reqVO.getDetailedAddress())
                .betweenIfPresent(MiniAddressDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(MiniAddressDO::getId));
    }

    default List<MiniAddressDO> selectList(AddressExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<MiniAddressDO>()
                .eqIfPresent(MiniAddressDO::getCustomerId, reqVO.getCustomerId())
                .likeIfPresent(MiniAddressDO::getFullName, reqVO.getFullName())
                .eqIfPresent(MiniAddressDO::getMobile, reqVO.getMobile())
                .eqIfPresent(MiniAddressDO::getAddress, reqVO.getAddress())
                .eqIfPresent(MiniAddressDO::getLongitude, reqVO.getLongitude())
                .eqIfPresent(MiniAddressDO::getLatitude, reqVO.getLatitude())
                .eqIfPresent(MiniAddressDO::getDetailedAddress, reqVO.getDetailedAddress())
                .betweenIfPresent(MiniAddressDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(MiniAddressDO::getId));
    }

}
